'use strict';

describe('show templateDataFilter', function() {
  var $show;
  beforeEach(module('fbdApp.templateModule'));
  beforeEach(inject(function(_$filter_) {
    $show = _$filter_('showTempFilter');
  }));

  it('should be defined', function(done) {
    expect($show).toBeDefined();
    return done();
  });

  var rules = [{
      mode: 'signs',
      beginText: '<<<',
      type: 1,
      expression: '123',
      name: 'rule1'
    }, {
      mode: 'signs',
      beginText: '<<<',
      endText: 'a',
      type: 2,
      expression: '12312',
      name: 'rule2'
    }, {
      mode: 'signs',
      beginText: '<<<',
      endText: 'a',
      type: 2,
      expression: '12312',
      name: 'rule3'
    },
    [{
      mode: 'signs',
      beginText: '<<<',
      type: 1,
      expression: '123',
      name: 'sub1'
    }, {
      mode: 'signs',
      beginText: '<<<',
      type: 1,
      expression: '123',
      name: 'sub2'
    }]
  ];

  var result = {
    main: {
      rule1: [{
        location: [15, 23],
        rule2: [{
          location: [0, 2],
          text: 'ss'
        }, {
          location: [0, 2],
          text: 's1'
        }],
        rule3: [{
          location: [0, 2],
          text: 'ss'
        }],
        valid: true,
        text: 'abcd'
      }, {
        location: [15, 23],
        rule2: [{
          location: [0, 2],
          text: 'ssaa'
        }],
        rule3: [{
          location: [0, 2],
          text: 'ssaaa'
        }],
        valid: true,
        text: 'abcd'
      }],
      valid: true,
      text: 'abcdsdfsd'
    },
    others: {}
  };

  // var expected = {
  //   rule: {
  //     head: ['rule2', 'rule3'],
  //     res: [{
  //       rule2: ['ss' ,'s1'],
  //       rule3: ['ss'],
  //     }, {
  //       rule2: ['ssaa'],
  //       rule3: ['ssaaa'],
  //     }]
  //   },
  //   template: {

  //   }
  // };

  var expected = {
    rule: {
      head: ['rule2', 'rule3'],
      res: [
        [['ss' ,'s1'], ['ss']],
        [['ssaa'], ['ssaaa']]
      ]
    },
    template: {

    }
  };

  it('show test result', function(done) {

    expect($show(rules, result)).toEqual(expected);
    return done();
  });


});
